package cn.com.zhuxulin.android.demos.activities;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import cn.com.zhuxulin.android.demos.R;

public class OpenSettings extends Activity {

	private ListView listView;
	private HashMap<String, String> map;
	private ArrayList<HashMap<String, String>> listValues;
	private HashMap<String, String> SLists;
	private SimpleAdapter listAdapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.open_settings);
		listView = (ListView) findViewById(R.id.settings);
		map = null;
		listValues = new ArrayList<HashMap<String, String>>();
		SLists = new HashMap<String, String>();
		SLists.put("ACTION_ACCESSIBILITY_SETTINGS",
				Settings.ACTION_ACCESSIBILITY_SETTINGS);
		SLists.put("ACTION_ADD_ACCOUNT", Settings.ACTION_ADD_ACCOUNT);
		SLists.put("ACTION_AIRPLANE_MODE_SETTINGS",
				Settings.ACTION_AIRPLANE_MODE_SETTINGS);
		SLists.put("ACTION_APN_SETTINGS", Settings.ACTION_APN_SETTINGS);
		SLists.put("ACTION_APPLICATION_DEVELOPMENT_SETTINGS",
				Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS);
		SLists.put("ACTION_APPLICATION_SETTINGS",
				Settings.ACTION_APPLICATION_SETTINGS);
		SLists.put("ACTION_BLUETOOTH_SETTINGS",
				Settings.ACTION_BLUETOOTH_SETTINGS);
		SLists.put("ACTION_DATA_ROAMING_SETTINGS",
				Settings.ACTION_DATA_ROAMING_SETTINGS);
		SLists.put("ACTION_DATE_SETTINGS", Settings.ACTION_DATE_SETTINGS);
		SLists.put("ACTION_DEVICE_INFO_SETTINGS",
				Settings.ACTION_DEVICE_INFO_SETTINGS);
		SLists.put("ACTION_DISPLAY_SETTINGS", Settings.ACTION_DISPLAY_SETTINGS);
		SLists.put("ACTION_INPUT_METHOD_SETTINGS",
				Settings.ACTION_INPUT_METHOD_SETTINGS);
		SLists.put("ACTION_INTERNAL_STORAGE_SETTINGS",
				Settings.ACTION_INTERNAL_STORAGE_SETTINGS);
		SLists.put("ACTION_LOCALE_SETTINGS", Settings.ACTION_LOCALE_SETTINGS);
		SLists.put("ACTION_LOCATION_SOURCE_SETTINGS",
				Settings.ACTION_LOCATION_SOURCE_SETTINGS);
		SLists.put("ACTION_MANAGE_APPLICATIONS_SETTINGS",
				Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS);
		SLists.put("ACTION_MEMORY_CARD_SETTINGS",
				Settings.ACTION_MEMORY_CARD_SETTINGS);
		SLists.put("ACTION_NETWORK_OPERATOR_SETTINGS",
				Settings.ACTION_NETWORK_OPERATOR_SETTINGS);
		SLists.put("ACTION_PRIVACY_SETTINGS", Settings.ACTION_PRIVACY_SETTINGS);
		SLists.put("ACTION_QUICK_LAUNCH_SETTINGS",
				Settings.ACTION_QUICK_LAUNCH_SETTINGS);
		SLists.put("ACTION_SEARCH_SETTINGS", Settings.ACTION_SEARCH_SETTINGS);
		SLists.put("ACTION_SECURITY_SETTINGS",
				Settings.ACTION_SECURITY_SETTINGS);
		SLists.put("ACTION_SETTINGS", Settings.ACTION_SETTINGS);
		SLists.put("ACTION_SOUND_SETTINGS", Settings.ACTION_SOUND_SETTINGS);
		SLists.put("ACTION_SYNC_SETTINGS", Settings.ACTION_SYNC_SETTINGS);
		SLists.put("ACTION_USER_DICTIONARY_SETTINGS",
				Settings.ACTION_USER_DICTIONARY_SETTINGS);
		SLists.put("ACTION_WIFI_IP_SETTINGS", Settings.ACTION_WIFI_IP_SETTINGS);
		SLists.put("ACTION_WIFI_SETTINGS", Settings.ACTION_WIFI_SETTINGS);
		SLists.put("ACTION_WIRELESS_SETTINGS",
				Settings.ACTION_WIRELESS_SETTINGS);
//		SLists.put("AUTHORITY", Settings.AUTHORITY);
//		SLists.put("EXTRA_AUTHORITIES", Settings.EXTRA_AUTHORITIES);

		for (Iterator<Map.Entry<String, String>> it = SLists.entrySet()
				.iterator(); it.hasNext();) {
			Map.Entry<String, String> e = (Map.Entry<String, String>) it.next();
			map = new HashMap<String, String>();
			map.put("Setting", e.getKey());
			map.put("intent", e.getValue());
			listValues.add(map);
		}
	}

	@Override
	protected void onStart() {
		super.onStart();
		listAdapter = new SimpleAdapter(this, listValues,
				R.layout.open_settings_item,
				new String[] { "Setting", "intent" }, new int[] { R.id.setting,
						R.id.intent });
		listView.setAdapter(listAdapter);
		listView.setOnItemClickListener(new OnItemClickListener() {

			public void onItemClick(AdapterView<?> adapter, View view,
					int which, long arg3) {
				startActivity(new Intent(listValues.get(which).get("intent")));
			}
		});
	}
}
